﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Input;

namespace MiaProject
{
    class Build
    {
        public Model model;
        public Vector3 pos;
        public float rotation;

        public Build()
        {
            this.pos = Vector3.Zero;
        }//end constructor
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

        /**
        Desenha a plataforma
        */
        public void draw(Matrix view, Matrix projection, BoundingFrustum frustum)
        {
            // Cria um ContainmentType, de tipo Disjoint
            ContainmentType currentContainmentType = ContainmentType.Disjoint;

            // Pega a esfera do objeto…
            BoundingSphere meshBoundingSphere = new BoundingSphere(this.pos, model.Meshes[0].BoundingSphere.Radius * 2.5f);

            //…e testa com o Frustum da Camera
            currentContainmentType = frustum.Contains(meshBoundingSphere);
            //Se a esfera estiver dentro do frustum…
            if (currentContainmentType != ContainmentType.Disjoint)
            {
                Matrix world = Matrix.Identity * Matrix.CreateRotationY(rotation) * Matrix.CreateTranslation(pos);
                this.model.Draw(world, view, projection);
            }

        }//end of method
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    }
}
